<?php

/***
 * Spoon SQL class
 * 
 * * * * * * * * * * * * * * * *
 * Class is designed for       *
 * use with the Fork Framework *
 * * * * * * * * * * * * * * * *
 * 
 * Spoon uses config.ini to setup database connects
 * 
 */



class Spoon
{
	private $databaseConnection;
	private $tableName;
	private $query;
	private $result;
	
	
	public function __construct()
	{
		$ini = parse_ini_file("config.ini", true);
		/*
		 * Setup for just mysql/pdo as of now.
		 * Switch statement will go here that will
		 * be based off $ini['db']['driver'] 
		 */
		
		$host     = $ini['db']['host'];
		$username = $ini['db']['username'];
		$password = $ini['db']['password'];
		$database = $ini['db']['database'];
		
		try
		{
			$this->databaseConnection = new PDO("mysql:host=$host;dbname=$database, $user, $pass");
		}
		catch (PDOException $e)
		{
			echo "error: " . $e->getMessage();
			die;
		}
		
			
	}//end __construct
	
	public function __get($obj)
	{
		switch($obj)
		{
			case "databaseConnection":
				return $this->db;
				break;
			case "query":
				return $this->qry;
				break;
			case "result":
				return $this->result;
				break;
			case "tableName":
				return $this->tableName;
				break;
		}//end switch
	}//end __get

	public function __set($obj, $val)
	{
		switch($obj)
		{
			case "databaseConnection":
				$this->databaseConnection = $val;
				break;
			case "query":
				$this->query = $val;
				break;
			case "result":
				$this->result = $val;
				break;
			case "tableName":
				$this->tableName = $val;
		}//end switch
	}//end __set
	
	
	
	
	
	
	
	
	
}//end Spoon

?>












































